<?php

    $status = (null) ? 'closed' : 'open';
    $url = 'index.php?dir=' . $dir . '&sub=' . $sub;
    
    if ($subEvents) {
	
	echo '<h4 class="' . $status . '" onclick="swap(this);">Sub-Events (' . sizeof($subEvents) . ')</h4>';
	echo '<div>';
        echo '<table><tbody>';
	
        echo '<tr><th>#</th><th>ID</th><th>Title</th><th>Location</th><th>Time Frame</th><th>Date</th></tr>';
        
        foreach ($subevents as $i=>$subEvent) {
            echo '<tr>';
            echo '<td>' . $i . '</td>';
            echo '<td>' . $subEvent->getId() . '</td>';
            echo '<td><a href="#">' . $subEvent->getTitle() . '</a></td>';
            echo '<td><a href="#">' . $location->getTitle() . '</a></td>';
            echo '<td>' . $subEvent->getStartTime() . ' - ' . $subEvent->getEndTime() . '</td>';
            echo '<td>' . $subEvent->getDate() . '</td>';
            echo '</tr>';
        }
        echo '</tbody></table>';
        
    } else {
	
	echo '<h4>There are no Sub-Events!</h4>';
	echo '<div>';

    }
    echo '</div>';
    echo '<button class="create" onclick="window.location="' . $url . '&act=edit">Add Sub-Event</button>';

?>